package com.atguigu.consumer.service;

import com.atguigu.consumer.sao.UserSao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service;

/**
 * @author 郑启
 * @date 2021/05/13 17:01
 */
@RefreshScope
@Service
public class UserService {
	@Value("${spring.profiles.active}")
	private String profile;

	@Value("${config.info}")
	private String configInfo;

	@Autowired
	@Qualifier("com.atguigu.consumer.sao.UserSao")
	private UserSao userSao;

	public String getProfile() {
		return userSao.getProfile("consumer-" + profile);
	}

	public String getTimeout() {
		return userSao.getTimeout();
	}

	public String getDivide(int divisor) {
		return userSao.getDivide(0 / (divisor - 2));
	}

	public String getConfigInfo() {
		return configInfo + "--->" + userSao.getConfigInfo();
	}
}
